package logic

import (
	"fmt"
	"server/enity"
	"server/models"
)

/*
Date:2021/11/22
Time:11:11 下午
*/
type nurseLogic struct {
}

var NurseLogicInstance = new(nurseLogic)

func (l *nurseLogic) UpdateNurse(id int, param *enity.NurseReq) (err error) {
	model := models.NewNurse()

	err = model.GetById(id)
	if err != nil {
		return
	}

	model.Name = param.Name
	model.Address = param.Address
	model.Sex = param.Sex
	model.Age = param.Age
	model.Position = param.Position
	model.Specialty = param.Specialty
	model.Education = param.Education
	model.Age = param.Age
	model.WorkTime = param.WorkTime

	return model.Update()
}

func (l *nurseLogic) AddNurse(param *enity.NurseReq) (err error) {
	model := models.NewNurse()
	model.Name = param.Name
	model.Address = param.Address
	model.Sex = param.Sex
	model.Age = param.Age
	model.Position = param.Position
	model.Specialty = param.Specialty
	model.Education = param.Education
	model.Age = param.Age
	model.WorkTime = param.WorkTime
	fmt.Printf("%+v", model)
	return model.Add()
}
